using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit.Sdk;
using Assignment5;
using System.Collections.Generic;
using System;

namespace Assignment5.TestEquals
{
    [TestClass()]
    public class UnitTest1
    {
        [TestMethod()]
        public void EqualsTest()
        {
            Dictionary<Goods, int> oC = new Dictionary<Goods, int>();
            oC.Add(new Goods("A", 200), 10);
            oC.Add(new Goods("B", 100), 20);
            Customer c = new Customer("Bob", true);
            Customer c1 = new Customer("Alice", true);
            Time time = new Time(2023, 3, 22, 19, 53);
            OrderService orderService1 = new OrderService();

            Order order = orderService1.AddOrder(c, oC, time);
            Order order1 = orderService1.AddOrder(c1, oC, time);
            Assert.AreEqual(order.Equals(order1), false);
            Assert.AreEqual(new OrderDetail(order).Equals(new OrderDetail(order)), true);

        }
        [TestMethod()]
        public void searchTest()
        {
            Dictionary<Goods, int> oC = new Dictionary<Goods, int>();
            Goods A = new Goods("A", 200);
            oC.Add(A, 10);
            oC.Add(new Goods("B", 100), 20);
            Customer c = new Customer("Bob", true);
            Customer c1 = new Customer("Alice", true);
            Time time = new Time(2023, 3, 22, 19, 53);
            OrderService orderService1 = new OrderService();
            orderService1.AddOrder(c, oC, time);
            orderService1.AddOrder(c1, oC, time);
            Assert.AreEqual(2,orderService1.Search(A).Count);
        }
        [TestMethod()]
        public void RemoveTest()
        {
            Dictionary<Goods, int> oC = new Dictionary<Goods, int>();
            Goods A = new Goods("A", 200);
            oC.Add(A, 10);
            oC.Add(new Goods("B", 100), 20);
            Customer c = new Customer("Bob", true);
            Customer c1 = new Customer("Alice", true);
            Time time = new Time(2023, 3, 22, 19, 53);
            OrderService orderService1 = new OrderService();
            orderService1.AddOrder(c, oC, time);
            orderService1.AddOrder(c1, oC, time);
            orderService1.RemoveOrder(orderService1.Search(A));
            Assert.AreEqual(0, orderService1.Search(A).Count);
        }
    }
}

namespace TestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestTostring1()
        {
            Dictionary<Goods, int> oC=new Dictionary<Goods, int>();
            oC.Add(new Goods("A", 200), 10);
            Customer c=new Customer("Bob",true);
            Time time = new Time(2023, 3, 22, 19, 53);
            OrderService orderService = new OrderService();
            Order order = orderService.AddOrder(c, oC, time);
            Assert.AreEqual("Order time: 2023/3/22 19:53, Customer: Bob\r\n", order.ToString());
        }
        [TestMethod]
        public void TestTostring2()
        {
            Dictionary<Goods, int> oC = new Dictionary<Goods, int>();
            oC.Add(new Goods("A", 200), 10);
            oC.Add(new Goods("B", 100), 20);
            Customer c = new Customer("Bob", true);
            Customer c1 = new Customer("Alice", true);
            Time time = new Time(2023, 3, 22, 19, 53);
            OrderService orderService1 = new OrderService();
            Order order = orderService1.AddOrder(c, oC, time);
            Order order1= orderService1.AddOrder(c1, oC, time);
            Assert.AreEqual("Order time: 2023/3/22 19:53, Customer: Alice\r\n", order1.ToString());
        }
        [TestMethod]
        public void TestTostring3()
        {
            Dictionary<Goods, int> oC = new Dictionary<Goods, int>();
            oC.Add(new Goods("A", 200), 10);
            oC.Add(new Goods("B", 100), 20);
            Customer c = new Customer("Bob", true);
            Customer c1 = new Customer("Alice", true);
            Time time = new Time(2023, 3, 22, 19, 53);
            OrderService orderService1 = new OrderService();
            Order order = orderService1.AddOrder(c, oC, time);
            Order order1 = orderService1.AddOrder(c1, oC, time);
            OrderDetail detail = new OrderDetail(order1);
            Assert.AreEqual("Order time: 2023/3/22 19:53, Customer: Alice\r\n    " +
                "Goods info: Goods name: A, Price: 200, num: 10\r\nGoods name: B, Price: 100, num: 20\r\n" +
                "Money Amount: 3600\r\n", detail.ToString());
        }
    }
}
